************************************************************************************************************************
*											 Reproduction code for: 												   *
*************** Perceptions of Policy Responsiveness: The Effects of Egocentric and Sociotropic Congruence *************
***************************** Sven Hillen, Nils Steiner & Claudia Landwehr *********************************************
****************************************** West European Politics ******************************************************
************************************************************************************************************************

/*
Instructions:
This do-file reproduces all findings reported in the article listed above.
To reproduce the findings, do the following
1. Install ados and graph schemes used (if necessary), as follows
	ssc install fre
	ssc install center
	ssc install coefplot
	ssc install estout
	net install grc1leg, from(http://www.stata.com/users/vwiggins/) 
	ssc install schemepack, replace all
2. Download datasets & auxiliary do-files used:
	a) ESS data for rounds 6 and 10: https://ess.sikt.no/en/data-builder/?tab=round_country&rounds=5+9+10&seriesVersion=786
	b) Data with government positions from our reproduction archive: GovPos.dta
	c) Data with macro-level controls (V-Dem & SWIID) from our reproduction archive: MacroControls.dta
3. Put the three datasets and this reproduction do-file into one folder (and set this as the working directory)
4. Run the code below on the combined dataset
*/


*** set working directory


**# Bookmark #1
************************************************************************************************************************
*************************************************** General Settings ***************************************************
************************************************************************************************************************
	set more off, perm
	version 18.0
	set scheme white_tableau
	graph set window fontface "Times New Roman"

	
**# Bookmark #2
************************************************************************************************************************
*************************************************** Open and Recode ESS data *******************************************
************************************************************************************************************************
clear

***** Open ESS Data for rounds 6 and 10
use "ESS-Data-Wizard-subset-2023-09-25.dta", clear


***** Country identifiers & drop countries 
fre cntry


* Enter full country name
	clonevar country_name=cntry
	replace country_name= "Albania" if cntry=="AL"
	replace country_name= "Austria" if cntry=="AT"
	replace country_name= "Belgium" if cntry=="BE"
	replace country_name= "Bulgaria" if cntry=="BG"
	replace country_name= "Switzerland" if cntry=="CH"
	replace country_name= "Cyprus" if cntry=="CY"
	replace country_name= "Czech Republic" if cntry=="CZ"
	replace country_name= "Germany" if cntry=="DE"
	replace country_name= "Denmark" if cntry=="DK"
	replace country_name= "Estonia" if cntry=="EE"
	replace country_name= "Spain" if cntry=="ES"
	replace country_name= "Finland" if cntry=="FI"
	replace country_name= "France" if cntry=="FR"
	replace country_name= "Great Britain" if cntry=="GB"
	replace country_name= "Greece" if cntry=="GR"
	replace country_name= "Croatia" if cntry=="HR"
	replace country_name= "Hungary" if cntry=="HU"
	replace country_name= "Ireland" if cntry=="IE"
	replace country_name= "Iceland" if cntry=="IS"
	replace country_name= "Israel" if cntry=="IL"
	replace country_name= "Italy" if cntry=="IT"
	replace country_name= "Lithuania" if cntry=="LT"
	replace country_name= "Latvia" if cntry=="LV"
	replace country_name= "Montenegro" if cntry=="ME"
	replace country_name= "North Macedonia" if cntry=="MK"
	replace country_name= "Netherlands" if cntry=="NL"
	replace country_name= "Norway" if cntry=="NO"
	replace country_name= "Poland" if cntry=="PL"
	replace country_name= "Portugal" if cntry=="PT"
	replace country_name= "Serbia" if cntry=="RS"
	replace country_name= "Russia" if cntry=="RU"
	replace country_name= "Sweden" if cntry=="SE"
	replace country_name= "Slovenia" if cntry=="SI"
	replace country_name= "Slovakia" if cntry=="SK"
	replace country_name= "Ukraine" if cntry=="UA"
	replace country_name= "Kosovo" if cntry=="XK"

	
* create an identifier for country and ESS round
	gen countryround= country_name+ string(essround,"%02.0f")


* Drop data for country-waves not covered by CHES
	// never covered by CHES (regular and candidate):
	drop if country_name=="Israel" 
	drop if country_name=="Kosovo" 
	drop if country_name=="Russia" 

	// covered only by CHES Candidate
	drop if country_name=="Albania" 
	drop if country_name=="Montenegro" 
	drop if country_name=="North Macedonia" 
	drop if country_name=="Serbia" 
	drop if country_name=="Ukraine"

	// Iceland only covered by CHES in 2019
	drop if countryround=="Iceland06"  

	codebook country_name
		// 28 remaining countries
	
	
* create numerical country_id for all remaining countries
	gen country_id=.
	replace country_id=1 if cntry=="AT"
	replace country_id=2 if cntry=="BE"
	replace country_id=3 if cntry=="BG"
	replace country_id=4 if cntry=="CH"
	replace country_id=5 if cntry=="CY"
	replace country_id=6 if cntry=="CZ"
	replace country_id=7 if cntry=="DE"
	replace country_id=8 if cntry=="DK"
	replace country_id=9 if cntry=="EE"
	replace country_id=10 if cntry=="ES"
	replace country_id=11 if cntry=="FI"
	replace country_id=12 if cntry=="FR"
	replace country_id=13 if cntry=="GB"
	replace country_id=14 if cntry=="GR"
	replace country_id=15 if cntry=="HR"
	replace country_id=16 if cntry=="HU"
	replace country_id=17 if cntry=="IE"
	replace country_id=18 if cntry=="IS"
	replace country_id=19 if cntry=="IT"
	replace country_id=20 if cntry=="LT"
	replace country_id=21 if cntry=="LV"
	replace country_id=22 if cntry=="NL"
	replace country_id=23 if cntry=="NO"
	replace country_id=24 if cntry=="PL"
	replace country_id=25 if cntry=="PT"
	replace country_id=26 if cntry=="SE"
	replace country_id=27 if cntry=="SI"
	replace country_id=28 if cntry=="SK"
	label define country_id 1 "AT" ///
						2 "BE" ///
						3 "BG" ///
						4 "CH" ///
						5 "CY" ///
						6 "CZ" ///
						7 "DE" ///
						8 "DK" ///
						9 "EE" ///
						10 "ES" ///
						11 "FI" ///
						12 "FR" ///
						13 "GB" ///
						14 "GR" ///
						15 "HR" ///
						16 "HU" ///
						17 "IE" ///
						18 "IS" ///
						19 "IT" ///
						20 "LT" ///
						21 "LV" ///
						22 "NL" ///
						23 "NO" ///
						24 "PL" ///
						25 "PT" ///
						26 "SE" ///
						27 "SI" ///
						28 "SK"
	label values country_id country_id

	* Dummy for Eastern European countries
	gen east = 1 if cntry=="BG" | cntry=="HR" | cntry=="CY" | cntry=="CZ" | cntry=="EE" | cntry=="HU" | cntry=="LT" | cntry=="LV" | cntry=="PL" | cntry=="SI" | cntry=="SK"  
	replace east=0 if cntry=="AT" | cntry=="BE" | cntry=="CH" | cntry=="DE" | cntry=="DK" | cntry=="ES" | cntry=="FI" | cntry=="FR" | cntry=="GB" | cntry=="GR" | cntry=="IE" ///
					| cntry=="IS" |  cntry=="IT" | cntry=="NL" | cntry=="NO" | cntry=="PT" |cntry=="SE"

		// 11 Eastern European countries
		// 17 Western European countries
	

***** Recoding of responsiveness variables 

	*** Preference for reponsiveness: "Best for democracy: government changes policies in response to what most people think"
	fre chpldm
	fre chpldm if essround==6
	fre chpldm if essround==10
	fre scchpldm if essround==10
	
		/* some countries switched to a self-completion approach due to the pandemic. 
		Question differs as it cannot be answered with "it depends". */
		
	* Recode these variables and their value labels
	recode chpldm (1=1 "change") (2=2 "stick") (5=3 "it depends"), gen(pref_responsiveness_int)
	recode scchpldm (1=1 "change") (2=2 "stick"), gen(pref_responsiveness_sc) 
	
	* Combine both in one variable 
	clonevar pref_responsiveness=pref_responsiveness_int
	replace pref_responsiveness=pref_responsiveness_sc if pref_responsiveness==.	
		
	* Dummy variable: "the government should change its planned policies" -> 1; "the government should change its planned policies" -> 0
	recode pref_responsiveness (2=0 "stick") (1=1 "change") (3=.), gen(pref_responsiveness_dummy) 
	
	
	*** Perceived reponsiveness: "How often you think the government changes its planned policies in response to what most people think'?"
	fre chpldmc
	gen perc_responsiveness=chpldmc
	label variable perc_responsiveness "perceived responsiveness"
	
	tab pref_responsiveness perc_responsiveness	
	
	
	*** Importance of responsiveness: "How important do you think it is for democracy in general that the government changes its planned policies in response to what most people think?"
	fre chpldmi
	clonevar importance_responsiveness=chpldmi
	


***** Recoding of other variables 

*** Alternative Dependent variable

	* External Efficacy: "How much would you say the political system in [country] allows people like you to have a say in what the government does?" (ONLY PART OF ESS 10)
	fre psppsgva
	recode psppsgva (1=0) (2=1) (3=2) (4=3) (5=4) (.a .b .c=.), gen(efficacy)
	gen efficacy_st=efficacy/4

	* Satisfaction with democracy
	fre stfdem
	gen stfdem_st=stfdem/10

	pwcorr perc_responsiveness efficacy_st stfdem_st


*** Independent variables micro-level

	* gender
	fre gndr
	recode gndr (1=1) (2=0) (.a=.), gen(male)
	
	label variable male "gender: male"

	* age
	fre agea
	gen age_st=agea/100

	recode agea (1/30=0 "age: -30") (31/45=1 "age: 31-45") (46/65=2 "age: 46-65") (66/130=3 "age: 66-"), gen(age_groups)

	* education
	fre eisced
	recode eisced (1=0) (2=1) (3 4=2) (5=3) (6 7=4) (55=5) (.a .b .c=.), gen(education)
	label define educ 0 "Below lower secondary" 1 "Lower secondary" 2 "Upper secondary" 3 "Post-secondary non-tertiary" 4 "Tertiary" 5 "Other"
	label values education educ

	* income
	fre hinctnta
	gen hinctnta_st=(hinctnta-1)/9
	
	recode hinctnta (1 2=0 "lowest quintile") (3 4=1 "2nd quintile") (5 6=2 "3rd quintile") (7 8=3 "4th quintile") (9 10=4 "highest quintile"), gen(hinctnta_quint)

	* place in society
	fre plinsoc

	* political interest
	fre polintr
	recode polintr (1=3) (2=2) (3=1) (4=0), gen(pol_interest)
	gen pol_interest_st=pol_interest/3

	* satisfaction with economy
	fre stfeco
	gen stfeco_st=stfeco/10

	* Left-Right
	fre lrscale
	gen lrscale_st=lrscale/10
	recode lrscale (.b=0) (0 1 2 3=1) (4 5 6=2) (7 8 9 10=3), gen(lrcat)
	label define lrcat 0 "Don't know" 1 "Left" 2 "Middle" 3 "Right"
	label values lrcat lrcat
	
	* Winner/Loser 
	gen incumbent=0 // Consequence: Observations with missing values on the party vote variable are in the following defined as loser supporters. Thus, we define those as winners who explictily stated to have voted for one of the governing parties, and all others are coded zero (including those who say they did not vote, those who say they don't know whom they voted for and those who refused to answer).
	
		****** ESS 6 *********
		gen long intvdate=inwyys*10000+inwmms*100+inwdds

			*Belgium
			replace incumbent=1 if (prtvtcbe==2 | prtvtcbe==12 | prtvtcbe==13 | prtvtcbe==9 | prtvtcbe==8 | prtvtcbe==5) & essround==6

			*Bulgaria
			replace incumbent=1 if intvdate <20130313 & prtvtcbg==1  & essround==6

			*Cyprus
			replace incumbent=1 if prtvtacy==1  & essround==6

			*Czech Republic
			replace incumbent=1 if (prtvtccz==5 | prtvtccz==3) & essround==6

			*Denmark
			replace incumbent=1 if (prtvtcdk==2 | prtvtcdk==4 | prtvtcdk==1) & essround==6

			*Estonia
			replace incumbent=1 if (prtvtdee==1 | prtvtdee==3) & essround==6

			*Finland
			replace incumbent=1 if (prtvtcfi==14 | prtvtcfi==5 | prtvtcfi==1 | prtvtcfi==2 | prtvtcfi==13 | prtvtcfi==12) & essround==6

			*France
			replace incumbent=1 if (prtvtcfr==7 | prtvtcfr==9 | prtvtcfr==12) & essround==6

			*Hungary
			replace incumbent=1 if prtvtdhu==3 & essround==6 

			*Iceland
			replace incumbent=1 if (prtvtais==1 | prtvtais==4) & essround==6

			*Ireland
			replace incumbent=1 if (prtvtaie==2 | prtvtaie==5) & essround==6

			*Italy
			replace incumbent=1 if (prtvtbit==8 | prtvtbit==1 | prtvtbit==5) & essround==6

			*Lithuania
			replace incumbent=1 if (prtvalt1==3 | prtvalt1==7 | prtvalt1==8 | prtvalt1==9) & essround==6

			*Netherlands
			replace incumbent=1 if intvdate <20121105 & prtvtenl==1 & essround==6
			replace incumbent=1 if intvdate>=20121105 & (prtvtenl==1 | prtvtenl==2) & essround==6

			*Norway
			replace incumbent=1 if (prtvtano==3 | prtvtano==2 | prtvtano==6) & essround==6

			*Poland
			replace incumbent=1 if (prtvtcpl==2 | prtvtcpl==5) & essround==6

			*Portugal
			replace incumbent=1 if (prtvtbpt==2 | prtvtbpt==10) & essround==6

			*Slovakia
			replace incumbent=1 if prtvtcsk==3 & essround==6

			*Slovenia
			replace incumbent=1 if (prtvtdsi==8 | prtvtdsi==1 | prtvtdsi==3 | prtvtdsi==4 | prtvtdsi==5) & essround==6

			*Spain
			replace incumbent=1 if prtvtces==1 & essround==6

			*Sweden
			replace incumbent=1 if (prtvtbse==1 | prtvtbse==3 | prtvtbse==2 | prtvtbse==5) & essround==6

			*Switzerland
			replace incumbent=1 if (prtvtdch==2 | prtvtdch==1 | prtvtdch==3 | prtvtdch==4 | prtvtdch==7) & essround==6

			*United Kingdom
			replace incumbent=1 if (prtvtgb==1 | prtvtgb==3) & essround==6

			*Germany
			replace incumbent=1 if (prtvdde2==2 | prtvdde2==4) & essround==6		
			
		
		****** ESS 10 *********
		* Date the interview started
		gen startdate = dofc(inwds)

		* Date the interview ended
		gen enddate = dofc(inwde)
		
		count if startdate != enddate // 740 missing. These obs are assigned the enddate of the interview date if possible; the startdate otherwise.
		
		
		* Date of the interview based on enddate
		format enddate %td
		gen endyear = year(enddate)
		gen endmonth = month(enddate)
		gen endday = day(enddate)
		
		g long intvdate10 = endyear*10000 + endmonth*100 + endday
		
		fre intvdate10 // 21240 missing
		
		
		* Date of the interview based on startdate
		count if intvdate10 == . & startdate != .
		
		format startdate %td
		gen startyear = year(startdate)
		gen startmonth = month(startdate)
		gen startday = day(startdate)
		
		g long intvdate102 = startyear*10000 + startmonth*100 + startday
		
		
		* Assign startdate to intvdate if intvdate is missing
		replace intvdate10 = intvdate102 if intvdate10 == .
		drop intvdate102
		
		fre intvdate10 // 21210 missing. Mostly from countries that used self-completion (AT, DE, ES, IL, LV, PL, RS, SE). Plus a few from GB
		
		
		* Assign these respondents the date the data collection period in their respective countries ended
		replace intvdate10 = 20211206 if cntry == "AT" & essround == 10
		replace intvdate10 = 20220104 if cntry == "DE" & essround == 10
		replace intvdate10 = 20220531 if cntry == "ES" & essround == 10
		replace intvdate10 = 20220131 if cntry == "LV" & essround == 10
		replace intvdate10 = 20220525 if cntry == "PL" & essround == 10
		replace intvdate10 = 20220117 if cntry == "SE" & essround == 10
		replace intvdate10 = 20220209 if cntry == "GB" & essround == 10 & intvdate10 == .
		

		*** Winner Support
					
		*Austria
		replace incumbent=1 if (prtvtcat==2 | prtvtcat==5) & essround==10
			
		*Belgium
		replace incumbent=1 if (prtvtebe==1 | prtvtebe==2 | prtvtebe==4 | prtvtebe==7 | prtvtebe==9 | prtvtebe==10 | prtvtebe==11) & essround==10
			
		*Bulgaria
				/* Interviews took place between June 2021 and September 2021. Since 12 May 2021, Stefan Yanev 
				led a caretaker government. An election was held on 11 July 2021, but no government could be formed.
				Yanev stayed in office till Dezember 2021, when Kiril Petkow successfully formed a new government after
				another election in November 2021. --> Caretaker without party affiliation. No winner support */ 
			
		*Croatia
		replace incumbent=1 if (prtvtbhr==1 | prtvtbhr==9 | prtvtbhr==8) & essround==10
			
		*Cyprus
		replace incumbent=1 if (prtvtccy==8) & essround==10
			
		*Chzech Republic
		replace incumbent=1 if (prtvtecz==2 | prtvtecz==4) & essround==10
			
		*Estonia
		replace incumbent=1 if (prtvthee==1 | prtvthee==2) & essround==10
			
		*Finland
		replace incumbent=1 if (prtvtefi==18 | prtvtefi==3 | prtvtefi==2 | prtvtefi==17 | prtvtefi==16) & essround==10
			
		*France
		replace incumbent=1 if (prtvtefr==7 | prtvtefr==8) & essround==10
			
		*Germany
		replace incumbent=. if cntry=="DE" & essround==10
			// cabinet change during fieldwork and no date of interview available
			
		*Greece
		replace incumbent=1 if (prtvtdgr==1) & essround==10
			
		*Hungary
		replace incumbent=1 if (prtvtghu==3 | prtvtghu==5) & essround==10
			
		*Iceland
		replace incumbent=1 if (prtvtdis==11 | prtvtdis==9 | prtvtdis==5) & essround==10
			
		*Ireland
		replace incumbent=1 if (prtvtdie==1 | prtvtdie==2 | prtvtdie==6) & essround==10
			
		*Italyfre 
		replace incumbent=1 if (prtvtdit==1 | prtvtdit==2 | prtvtdit==3 | prtvtdit==4) & essround==10
				// PdL voters are coded as winners for the whole fieldwork despite the change in the goverment composition (because we cannot distinguish NCD [remained in government] voters from other PdL voters)
				
		*Latvia
		replace incumbent=1 if (prtvtalv==2 | prtvtalv==10 | prtvtalv==4 | prtvtalv==13) & essround==10 
			
		*Lithuania
		replace incumbent=1 if (prtvclt1==5 | prtvclt1==12 | prtvclt1==3) & essround==10	

		*Netherlands
		replace incumbent=1 if (prtvthnl==1 | prtvthnl==6 | prtvthnl==5 | prtvthnl==7) & essround==10
				
		*Norway
		replace incumbent=1 if (prtclbno==7 | prtclbno==4 | prtclbno==5) & intvdate10<20211014 & essround==10
		replace incumbent=1 if (prtclbno==3 | prtclbno==6) & intvdate10>=20211014 & essround==10
			
		*Poland
		replace incumbent=1 if (prtvtepl==5) & essround==10
			
		*Portugal
		replace incumbent=1 if prtvtdpt==18 & essround==10
			
		*Slovakia
		replace incumbent=1 if (prtvtesk==1 | prtvtesk==3 | prtvtesk==6 | prtvtesk==7) & essround==10
			
		*Slovenia
		replace incumbent=1 if (prtvtfsi==10 | prtvtfsi==4 | prtvtfsi==8) & essround==10
		replace incumbent=1 if (prtvtfsi==1) & intvdate10<20201218 & essround==10

		*Spain
		replace incumbent=1 if (prtvtfes==1 | prtvtfes==4 | prtvtfes==5) & essround==10
			
		*Sweden
		replace incumbent=1 if prtvtdse==6 & essround==10
			
		*Switzerland
		replace incumbent=1 if (prtvthch==1 | prtvthch==2 | prtvthch==3 | prtvthch==5 | prtvthch==7) & essround==10
			
		*United Kingdom
		replace incumbent=1 if prtvtdgb==1 & essround==10

		* CHECK		
		tab countryround incumbent
			// Contexts with only losers: Bulgaria10 (caretaker government)
	
***** Save processed ESS dataset
save "ESS_processed.dta", replace


			
**# Bookmark #3
*********************************************************************************************************************
*************************************** Merge macro-level data ******************************************************
*********************************************************************************************************************


*************************** 1. Government positions ***************************

* Create variable for cabinet number for merge command
	replace intvdate=intvdate10 if intvdate==.

	gen cabinet_number=1
	replace cabinet_number=2 if countryround=="Bulgaria10" & intvdate>=20210916 & intvdate<.
	replace cabinet_number=2 if countryround=="Bulgaria06" & intvdate>=20130313 & intvdate<.
	replace cabinet_number=2 if countryround=="Netherlands06" & intvdate>=20121105 & intvdate<.	
	replace cabinet_number=2 if countryround=="Norway10" & intvdate>=20211014 & intvdate<.		
	replace cabinet_number=2 if countryround=="Slovenia10" & intvdate>=20201218 & intvdate<. 	
	replace cabinet_number=2 if countryround=="Italy06" & intvdate>=20131118 & intvdate<.	

* Merge the cabinet data to the ESS dataset
	merge m:1 country_name essround cabinet_number using "GovPos.dta", gen(merge_govpos)

	* List cabinet data that could not be matched
	list countryround cabinet_name cabinet_number if merge_gov==2
		// Neehammer cannot be matched, we only assign Schallenberg to Austria in ESS 10 (Cabinet change does not matter because coalition stayed the same; only chancellor changed.)
	drop if merge_gov==2
	
	* List ESS country-rounds for which no cabinet data could be merged
	fre countryround if merge_gov==1	
		// All could be matched

		
	*** Year in which ESS fieldwork started 
	gen year=substr(ess_start, 1, 4)
	destring year, replace		
		
		
*************************** 2. Macro Controls ***************************
	merge m:1 country_name year using "MacroControls.dta", gen(merge_macrocontrols)
	
	drop if merge_macrocontrols==2
	
	save "ESS_processed.dta", replace
		
		

**# Bookmark #4
*********************************************************************************************************************
******************************************** Compute distances ******************************************************
*********************************************************************************************************************

	*** Individual distance
	* Left right
	sum lrscale_st lrgen_gov
	gen dist_lr=abs(lrscale_st-lrgen_gov)

	* Redistribution
	gen gincdif_st=(gincdif-1)/4
	sum gincdif_st redistribution_gov
	gen dist_redistr=abs(gincdif_st-redistribution_gov)

	* EU integration
	gen eu_st=(euftf)/10
	sum eu_st eu_position_gov
	gen dist_eu=abs(eu_st-eu_position_gov)

	* Social Lifestyle/Homosexuals
	gen freehms_st=(freehms-1)/4
	sum freehms_st sociallifestyle_gov
	gen dist_lifestyle=abs(freehms_st-sociallifestyle_gov)

	* Immigration
	gen immigr_st=((imsmetn+imdfetn+impcntr)-3)/9
	sum immigr_st immigration_gov
	gen dist_immigr=abs(immigr_st-immigration_gov)

	* Environment
	gen impenv_st=(impenv-1)/5
	sum impenv_st environment_gov
	gen dist_environm=abs(impenv_st-environment_gov)

	* GALTAN

	* Left-right synthesized
	gen lrsynth_st=(gincdif_st+freehms_st+immigr_st)/3
	sum lrsynth_st lrsynth_gov
	gen dist_lrsynth=abs(lrsynth_st-lrsynth_gov)

	* Mean of individual distances on redistribution, EU, social lifestyle issues and immigration
	gen dist_mean=(dist_redistr+dist_eu+dist_lifestyle+dist_immigr)/4
	

	*** Median citizen distance
	* Left right
	bysort cabinet_id: egen lrscale_st_med=median(lrscale_st)
	gen dist_med_lr=abs(lrscale_st_med-lrgen_gov)

	* Redistribution
	bysort cabinet_id: egen gincdif_st_med=median(gincdif_st)
	gen dist_med_redistr=abs(gincdif_st_med-redistribution_gov)

	* EU integration
	bysort cabinet_id: egen eu_st_med=median(eu_st)
	gen dist_med_eu=abs(eu_st_med-eu_position_gov)

	* Social Lifestyle/Homosexuals
	bysort cabinet_id: egen freehms_st_med=median(freehms_st)
	gen dist_med_lifestyle=abs(freehms_st_med-sociallifestyle_gov)

	* Immigration
	bysort cabinet_id: egen immigr_st_med=median(immigr_st)
	gen dist_med_immigr=abs(immigr_st_med-immigration_gov)

	* Environment
	bysort cabinet_id: egen impenv_st_med=median(impenv_st)
	gen dist_med_environm=abs(impenv_st_med-environment_gov)

	* Left-right synthesized
	bysort cabinet_id: egen lrsynth_st_med=median(lrsynth_st)
	gen dist_med_lrsynth=abs(lrsynth_st_med-lrsynth_gov)

	* Mean of median citizen distances on redistribution, EU, social lifestyle issues and immigration
	gen dist_med_mean=(dist_med_redistr+dist_med_eu+dist_med_lifestyle+dist_med_immigr)/4
		
		
	* Center distance variables for interactions	
	center dist_lr dist_med_lr
	center dist_mean dist_med_mean

	
	* save final dataset
	save "ESS_processed.dta", replace


**# Bookmark #5
*********************************************************************************************************************
*************************************** Descriptive Results *********************************************************
*********************************************************************************************************************


log using Run_reproduction_AllFixed



use "ESS_processed.dta"

	
	*** Figure 1: Preferences for responsiveness across countries and ESS waves
			preserve
			collapse pref_responsiveness_dummy, by(essround country_name)
			myaxis order=country_name, sort(mean pref_responsiveness_dummy) descending
			twoway (dot pref_responsiveness_dummy order if essround==6, msymbol(oh) msize(large) horizontal ylab(1/28, val) ///
				ytitle("") xtitle(Government should change policies in response to what most people think) ndots(0) dcolor(bg) ///
				xscale(range(0 1)) xlabel(0 "0%" .1 "10%" .2 "20%" .3 "30%" .4 "40%" .5 "50%" .6 "60%" .7 "70%" .8 "80%" .9 "90%" 1 "100%")) ///
				(dot pref_responsiveness_dummy order if essround==10, xline(.5) msize(large) horizontal ndots(0) dcolor(bg) legend(order(1 "ESS 6" 2 "ESS 10")) ///
				scale(*1.1) ysize(4.5) name(Figure1, replace))
			restore	
			
			graph export "Figure1.pdf", replace
			graph export "Figure1.jpg", width(5000) replace

	
	*** Figure 2: Perceptions of government responsiveness across countries and ESS waves
			preserve
			collapse perc_responsiveness, by(essround country_name)
			myaxis order=country_name, sort(mean perc_responsiveness) descending
			twoway (dot perc_responsiveness order if essround==6, msymbol(oh) msize(large) horizontal ylab(1/28, val) ///
				ytitle("") xtitle(Mean levels of perceived responsiveness) ndots(0) dcolor(bg) ///
				xscale(range(0 10)) xlabel(0(1)10)) ///
				(dot perc_responsiveness order if essround==10, xline(5) msize(large) horizontal ndots(0) dcolor(bg) legend(order(1 "ESS 6" 2 "ESS 10")) ///
				scale(*1.1) ysize(4.5) name(Figure2, replace))
			restore	

			graph export "Figure2.pdf", replace
			graph export "Figure2.jpg", width(5000) replace	
	
	
	*** Figure B1: Preferences for responsiveness (over trustee representation)
			histogram pref_responsiveness_int if essround==6, discrete percent ///
				yscale(range(0 100)) ylabel(0(20)100) ///
				xtitle(" ", size(zero)) ///
				xscale(range(1 3)) xlabel(1/3, valuelabel) title("ESS 6", size(medsmall)) ///
				addlabel addlabopts(mlabsize(small) mlabgap(0.5) yvarformat(%4.1f)) name(ess6, replace) nodraw

			histogram pref_responsiveness_int if essround==10, discrete percent ///
				yscale(range(0 100)) ylabel(0(20)100) ///
				xtitle(" ", size(zero)) ///
				xscale(range(1 3)) xlabel(1/3, valuelabel) title("ESS 10 (interview)", size(medsmall)) ///
				addlabel addlabopts(mlabsize(small) mlabgap(0.5) yvarformat(%4.1f)) name(ess10, replace) nodraw

			histogram pref_responsiveness_sc, discrete percent ///
				yscale(range(0 100)) ylabel(0(20)100) ///
				xtitle(" ", size(zero)) ///
				xscale(range(1 3)) xlabel(1/2, valuelabel) title("ESS 10 (self-completion)", size(medsmall)) ///
				addlabel addlabopts(mlabsize(small) mlabgap(0.5) yvarformat(%4.1f)) name(ess10sc, replace) nodraw

			histogram pref_responsiveness, discrete percent ///
				yscale(range(0 100)) ylabel(0(20)100) ///
				xtitle(" ", size(zero)) ///
				xscale(range(1 3)) xlabel(1/3, valuelabel) title("Overall", size(medsmall)) ///
				addlabel addlabopts(mlabsize(small) mlabgap(0.5) yvarformat(%4.1f)) name(all, replace) nodraw
				
			graph combine all ess6 ess10 ess10sc, col(2) imargin(0) iscale(*1.3) ysize(4.5) title("Government should change its planned policies in response to what most people think", size(medsmall)) title("vs.", size(medsmall) suffix) ///
				title("Government should stick to its planned policies regardless of what most people think", size(medsmall) suffix) title(" ", size(medsmall) suffix) ///
				name(FigureB1, replace)
				
				
	***	 Figure B2: Histogram with perceptions of government responsiveness (overall)
			histogram perc_responsiveness, discrete percent ///
				ylabel(0(5)20) ///
				xtitle("perceived responsiveness") ///
				xscale(range(1 3)) xlabel(0 "never" 1/9 10 "always", valuelabel) ///
				addlabel addlabopts(mlabsize(small) mlabgap(0.5) yvarformat(%4.1f)) name(FigureB2, replace) 
				
				graph export "FigureB2.pdf", replace
				graph export "FigureB2.jpg", width(5000) replace
			
			
	*** Figure B3: Perceptions of government responsiveness and of its importance for democracy
			levelsof country_id, local(countries)
				foreach i of local countries {
					levelsof country_name if country_id == `i', local(cntry_abbr)
					display `cntry_abbr'
					sum chpldmc if country_id == `i'
					local chpldmc_c = r(mean)
					sum chpldmi if country_id == `i'
					local chpldmi_c = r(mean)
					twoway (histogram perc_responsiveness, discrete percent lcolor(gs10) fcolor(gs10%70) ///
						xline(`chpldmc_c', lpattern(shortdash) lcolor(gs6) lwidth(medium))) ///
						(histogram importance_responsiveness, discrete percent fcolor(none) lcolor(red) lwidth(medthin) ytitle("") ///
						xline(`chpldmi_c', lpattern(shortdash) lcolor(cranberry) lwidth(medium)) ///
						legend(order(1 "Government does change policies" 2 "Government should change policies") position(6) rows(1)) ///
						title(`cntry_abbr') name(graph`i', replace)) if country_id == `i', nodraw 
				}
				
				grc1leg graph1 graph2 graph3 graph4 graph5 graph6 graph7 graph8 graph9 graph10 graph11 graph12 graph13 graph14 graph15 graph16 ///
					graph17 graph18 graph19 graph20 graph21 graph22 graph23 graph24 graph25 graph26 graph27 graph28 ///
					, ycommon xcommon legendfrom(graph1) row(7) xsize(4) iscale(*1.2) l1title("Percent", size(small)) imargin(vsmall) name(FigureB3, replace)
			
				graph combine FigureB3, ysize(5.8)
		
				graph export "FigureB3.pdf", replace
				graph export "FigureB3.jpg", width(5000) replace

				
	***	Table B1: Pairwise correlations between distance variables
			pwcorr dist_lr dist_med_lr dist_redistr dist_med_redistr dist_eu dist_med_eu dist_lifestyle dist_med_lifestyle dist_immigr dist_med_immigr

	
	
	*** Table A2: Data on cabinets
	preserve

		collapse (mean) perc_responsiveness dist_med_* lrgen_gov redistribution_gov eu_position_gov sociallifestyle_gov immigration_gov (last) country_name essround, by(cabinet_name)
		drop dist_med_environm
		drop if dist_med_lr==.

		drop dist_med_lrsynth
		order country_name essround cabinet_name  *gov dist* 
		gsort lrgen_gov

		list

		
	*** Figure B4: Perceptions of government responsiveness and policy distances to median citizen
		label variable perc_responsiveness "perceived responsiveness"	 
		label variable dist_med_lr "median voter distance: left-right"
		label variable dist_med_redistr "median voter distance: redistribution"
		label variable dist_med_eu "median voter distance: EU"
		label variable dist_med_lifestyle "median voter distance: lifestyle"
		label variable dist_med_immigr "median voter distance: immigration"		
			
		pwcorr perc_responsiveness dist_med_lr dist_med_redistr dist_med_eu dist_med_lifestyle dist_med_immigr, sig obs
			
		twoway (scatter perc_responsiveness dist_med_lr) (lfit perc_responsiveness dist_med_lr), xlabel(0 (.1) .6, gmin gmax) legend(off) ytitle("perceived responsiveness (mean)") text(7 0.45 "r=-0.33, p=0.02") name(gr1, replace) nodraw
		twoway (scatter perc_responsiveness dist_med_redistr) (lfit perc_responsiveness dist_med_redistr), xlabel(0 (.1) .6, gmin gmax) legend(off) ytitle("perceived responsiveness (mean)") text(7 0.45 "r=-0.14, p=0.34") name(gr2, replace) nodraw
		twoway (scatter perc_responsiveness dist_med_eu) (lfit perc_responsiveness dist_med_eu), xlabel(0 (.1) .6, gmin gmax) legend(off) ytitle("perceived responsiveness (mean)") text(7 0.45 "r=-0.10, p=0.48") name(gr3, replace) nodraw
		twoway (scatter perc_responsiveness dist_med_lifestyle) (lfit perc_responsiveness dist_med_lifestyle), xlabel(0 (.1) .6, gmin gmax) legend(off) ytitle("perceived responsiveness (mean)") text(7 0.45 "r=-0.23, p=0.11") name(gr4, replace) nodraw
		twoway (scatter perc_responsiveness dist_med_immigr) (lfit perc_responsiveness dist_med_immigr), xlabel(0 (.1) .6, gmin gmax) legend(off) ytitle("perceived responsiveness (mean)") text(7 0.45 "r=-0.10, p=0.50") name(gr5, replace) nodraw

		graph combine gr1 gr2 gr3 gr4 gr5, imargin(vsmall) iscale(*1.5) name(FigureB4, replace)

		graph export "FigureB4.pdf", replace
		graph export "FigureB4.jpg", width(5000) replace

		
	restore



**# Bookmark #6
************************************************************************************************************************
*********************************************** Regression analysis: Main **********************************************
************************************************************************************************************************
use "ESS_processed.dta"

	* define macro with control variables
	global controls "incumbent male i.age_groups ib4.education ib4.hinctnta_quint pol_interest_st"


*** Table 1: Multilevel regressions of perceptions of policy responsiveness  ****

* Left-right
	mixed perc_responsiveness ///
		dist_lr dist_med_lr ///
		$controls || cntry: || cabinet_id: , stddeviations   	
		eststo m1
		
		sum dist_lr dist_med_lr if e(sample)

* All single issues
	mixed perc_responsiveness ///
		dist_redistr dist_eu dist_lifestyle dist_immigr  ///
		dist_med_redistr dist_med_eu dist_med_lifestyle dist_med_immigr ///
		$controls || cntry: || cabinet_id: , stddeviations 	
		eststo m2
		
		sum dist_redistr dist_eu dist_lifestyle dist_immigr if e(sample)
		sum dist_med_lr dist_med_redistr dist_med_eu dist_med_lifestyle dist_med_immigr if e(sample)
		
		pwcorr dist_redistr dist_eu dist_lifestyle dist_immigr if e(sample)
		pwcorr dist_med_lr dist_med_redistr dist_med_eu dist_med_lifestyle dist_med_immigr if e(sample)

	
* Mean of single issues
	mixed perc_responsiveness ///
		dist_mean dist_med_mean ///
		$controls || cntry: || cabinet_id: , stddeviations 	
		eststo m3

		sum dist_mean dist_med_mean if e(sample)
	
* Left-right, interaction egocentric and sociotropic
	mixed perc_responsiveness ///
		c.c_dist_lr##c.c_dist_med_lr ///
		$controls || cntry: || cabinet_id: c.dist_lr, stddeviations   	
		eststo m4
		
		sum c_dist_lr c_dist_med_lr if e(sample)
	
* Mean of single issues, interaction egocentric and sociotropic
	mixed perc_responsiveness ///
		c.c_dist_mean##c.c_dist_med_mean ///
		$controls || cntry: ||  cabinet_id: c.dist_mean, stddeviations 	
		eststo m5
		
		
*** Write regression table ****
	esttab m1 m2 m3 m4 m5 using "RegTable.rtf", b(a2) se(a2) star(* 0.05 ** 0.01 *** 0.001) ///
			order(dist*) label nogaps nodepvars  ///
			replace			
	
	
*** Figure 3: Predicted perceptions of government responsiveness across distances  ****

	* Left-right
	estimates restore m1
	margins, at(dist_lr=(0 (.05) .85)) post
	eststo marg1
	
	estimates restore m1
	margins, at(dist_med_lr=(0 (.05) .35)) post
	eststo marg2 
	
	estimates restore marg1
	marginsplot, ///
			addplot(hist dist_lr if e(sample), percent yaxis(2) yscale(alt range(0 50) axis(2)) ytitle(" ", size(zero) axis(2)) ylabel(none, axis(2)) xlabel(0 (.1) .9, gmin gmax)) ///
			legend(off) ///
			title(" ", size(zero)) ytitle("Perceived responsiveness") xtitle("Egocentric distance") ///
			name(LR_ego, replace)

	estimates restore marg2
	marginsplot, ///
			addplot(hist dist_med_lr if e(sample), percent yaxis(2) yscale(alt range(0 50) axis(2)) ytitle(" ", size(zero) axis(2)) ylabel(none, axis(2)) xlabel(0 (.1) .4, gmin gmax)) ///
			legend(off) ///
			title(" ", size(zero)) ytitle("Perceived responsiveness") xtitle("Sociotropic distance") ///
			name(LR_soc, replace)		

	graph combine LR_ego LR_soc, imargin(vsmall) iscale(*1.3) ycommon title("Left-right (model 1)", size(medsmall)) name(LR, replace)
		
		
	* Mean distance
	estimates restore m3
	margins, at(dist_mean=(0 (.05) .85)) post
	eststo marg3
	
	estimates restore m3
	margins, at(dist_med_mean=(0 (.05) .4)) post
	eststo marg4 
	
	estimates restore marg3
	marginsplot, ///
			addplot(hist dist_mean if e(sample), percent yaxis(2) yscale(alt range(0 50) axis(2)) ytitle(" ", size(zero) axis(2)) ylabel(none, axis(2)) xlabel(0 (.1) .9, gmin gmax)) ///
			legend(off) ///
			title(" ", size(zero)) ytitle("Perceived responsiveness") xtitle("Egocentric distance") ///
			name(Mean_ego, replace)

	estimates restore marg4
	marginsplot, ///
			addplot(hist dist_med_mean if e(sample), percent yaxis(2) yscale(alt range(0 50) axis(2)) ytitle(" ", size(zero) axis(2)) ylabel(none, axis(2)) xlabel(0 (.1) .4, gmin gmax)) ///
			legend(off) ///
			title(" ", size(zero)) ytitle("Perceived responsiveness") xtitle("Sociotropic distance") ///
			name(Mean_soc, replace)		

	graph combine Mean_ego Mean_soc, imargin(vsmall) iscale(*1.3) ycommon title("Mean distance across issues (model 3)", size(medsmall)) name(Mean, replace)
		
		
	* Combine the plots for the two models
	graph combine LR Mean, row(2) ycommon iscale(*1.2) imargin(tiny) ysize(6) name(Figure3, replace)
		graph export "Figure3.pdf", replace
		graph export "Figure3.jpg", width(5000) replace	
	
	
*** Figure 4: Effects of sociotropic distance on perceived responsiveness ****
			
	* Left-right 
	
	estimates restore m4
	
	sum c_dist_lr c_dist_med_lr if e(sample)
	sum c_dist_lr c_dist_med_lr if e(sample), d

	margins, dydx(c_dist_med_lr) at(c_dist_lr=(-.25 (.05) .65)) post
	eststo marg5
	
	estimates restore marg5
		marginsplot, yline(0) ///
			addplot(hist c_dist_lr if e(sample), percent yaxis(2) yscale(alt range(0 50) axis(2)) ytitle(" ", size(zero) axis(2)) ylabel(none, axis(2)) xlabel(-.3 (.1) .7, gmin gmax)) legend(off) ///
			title("Left-right (model 4)", size(medsmall)) ytitle("Effect on perceived responsiveness") xtitle("Egocentric distance") ///
			name(lefright_soceff, replace)

			
	* Mean distance		
			
	estimates restore m5
		
	sum c_dist_mean c_dist_med_mean if e(sample)
	sum c_dist_mean c_dist_med_mean if e(sample), d
		
	margins, dydx(c_dist_med_mean) at(c_dist_mean=(-.3 (.05) .6)) post
	eststo marg6
	
	estimates restore marg6
		marginsplot, yline(0) ///
			addplot(hist c_dist_mean if e(sample), percent yaxis(2) yscale(alt range(0 50) axis(2)) ytitle(" ", size(zero) axis(2)) ylabel(none, axis(2)) xlabel(-.3 (.1) .6, gmin gmax)) legend(off) ///
			title("Mean distance (model 5)", size(medsmall)) ytitle("Effect on perceived responsiveness") xtitle("Egocentric distance") ///
			name(mean_soceff, replace)			
			

	* Combine the plots for the two models
	graph combine lefright_soceff mean_soceff, imargin(zero) iscale(*1.6) ycommon name(Figure4, replace)			
		
		graph export "Figure4.pdf", replace
		graph export "Figure4.jpg", width(5000) replace	
			

	
	
**# Bookmark #7
************************************************************************************************************************
*********************************************** Regression analysis: Robustness ****************************************
************************************************************************************************************************
use "ESS_processed.dta"

	* define macro with control variables
		global controls "incumbent male i.age_groups ib4.education ib4.hinctnta_quint pol_interest_st"
	
************************************************************************************************************************
******************************************** Table D1: Models without control variables ********************************
************************************************************************************************************************

* Left-right
	mixed perc_responsiveness ///
		dist_lr dist_med_lr ///
		|| cntry: || cabinet_id: , stddeviations   	
		eststo m1

* All single issues
	mixed perc_responsiveness ///
		dist_redistr dist_eu dist_lifestyle dist_immigr  ///
		dist_med_redistr dist_med_eu dist_med_lifestyle dist_med_immigr ///
		|| cntry: || cabinet_id: , stddeviations 	
		eststo m2

	
* Mean of single issues
	mixed perc_responsiveness ///
		dist_mean dist_med_mean ///
		|| cntry: || cabinet_id: , stddeviations 	
		eststo m3
	
* Left-right, interaction egocentric and sociotropic
	mixed perc_responsiveness ///
		c.c_dist_lr##c.c_dist_med_lr ///
		|| cntry: || cabinet_id: c.dist_lr, stddeviations   	
		eststo m4

	
* Mean of single issues, interaction egocentric and sociotropic
	mixed perc_responsiveness ///
		c.c_dist_mean##c.c_dist_med_mean ///
		|| cntry: ||  cabinet_id: c.dist_mean, stddeviations 	
		eststo m5
		
		
*** Write regression table ****
	esttab m1 m2 m3 m4 m5 using "RegTableD1.rtf", b(a2) se(a2) star(* 0.05 ** 0.01 *** 0.001) ///
			order(dist*) label nogaps nodepvars  ///
			replace			
			
	
		*** Figure D1: Effects of sociotropic distance on perceived responsiveness ****
					
			* Left-right 
			
			estimates restore m4
			
			sum c_dist_lr c_dist_med_lr if e(sample)
			sum c_dist_lr c_dist_med_lr if e(sample), d

			margins, dydx(c_dist_med_lr) at(c_dist_lr=(-.25 (.05) .65)) post
			eststo marg5
			
			estimates restore marg5
				marginsplot, yline(0) ///
					addplot(hist c_dist_lr if e(sample), percent yaxis(2) yscale(alt range(0 50) axis(2)) ytitle(" ", size(zero) axis(2)) ylabel(none, axis(2)) xlabel(-.3 (.1) .7, gmin gmax)) legend(off) ///
					title("Left-right (model 4)", size(medsmall)) ytitle("Effect on perceived responsiveness") xtitle("Egocentric distance") ///
					name(lefright_soceff, replace)

					
			* Mean distance		
					
			estimates restore m5
				
			sum c_dist_mean c_dist_med_mean if e(sample)
			sum c_dist_mean c_dist_med_mean if e(sample), d
				
			margins, dydx(c_dist_med_mean) at(c_dist_mean=(-.3 (.05) .6)) post
			eststo marg6
			
			estimates restore marg6
				marginsplot, yline(0) ///
					addplot(hist c_dist_mean if e(sample), percent yaxis(2) yscale(alt range(0 50) axis(2)) ytitle(" ", size(zero) axis(2)) ylabel(none, axis(2)) xlabel(-.3 (.1) .6, gmin gmax)) legend(off) ///
					title("Mean distance (model 5)", size(medsmall)) ytitle("Effect on perceived responsiveness") xtitle("Egocentric distance") ///
					name(mean_soceff, replace)			
					

			* Combine the plots for the two models
			graph combine lefright_soceff mean_soceff, imargin(zero) iscale(*1.6) ycommon name(FigureD1, replace)			
					
			graph export "FigureD1.pdf", replace
			graph export "FigureD1.jpg", width(5000) replace

			

************************************************************************************************************************
*********************************************** Table D2: Issues in separate models ************************************
************************************************************************************************************************

* Redistribution
mixed perc_responsiveness ///
	dist_redistr ///
	dist_med_redistr ///
	$controls || cntry: || cabinet_id: , stddeviations 	
	eststo m1
	
* EU integration
mixed perc_responsiveness ///
	dist_eu ///
	dist_med_eu ///
	$controls || cntry: || cabinet_id: , stddeviations 	
	eststo m2
	
* Social Lifestyle/Homosexuals
mixed perc_responsiveness ///
	dist_lifestyle ///
	dist_med_lifestyle ///
	$controls || cntry: || cabinet_id: , stddeviations 	
	eststo m3
	
* Immigration
mixed perc_responsiveness ///
	dist_immigr  ///
	dist_med_immigr ///
	$controls || cntry: || cabinet_id: , stddeviations 	
	eststo m4

	
*** Further exluding egocentric distances (only sociotropic congruence)

* Redistribution
mixed perc_responsiveness ///
	dist_med_redistr ///
	$controls || cntry: || cabinet_id: , stddeviations 	
	eststo m5
	
* EU integration
mixed perc_responsiveness ///
	dist_med_eu ///
	$controls || cntry: || cabinet_id: , stddeviations 	
	eststo m6

* Social Lifestyle/Homosexuals
mixed perc_responsiveness ///
	dist_med_lifestyle ///
	$controls || cntry: || cabinet_id: , stddeviations 	
	eststo m7
	
* Immigration
mixed perc_responsiveness ///
	dist_med_immigr ///
	$controls || cntry: || cabinet_id: , stddeviations 	
	eststo m8
		
	
*** Table ****
esttab m1 m2 m3 m4 m5 m6 m7 m8 using "RegTableD2.rtf", b(a2) se(a2) star(* 0.05 ** 0.01 *** 0.001) ///
		order(dist*) label nogaps nodepvars  ///
		replace		

		
		
************************************************************************************************************************
*********************************************** Table D3: z-standardized positions *************************************
************************************************************************************************************************	
	
**** z-standardize positions
egen lrscale_z = std(lrscale_st)
egen lrgen_gov_z = std(lrgen_gov)

egen gincdif_z = std(gincdif_st)
egen redistribution_gov_z = std(redistribution_gov)

egen eu_z = std(eu_st)
egen eu_position_gov_z = std(eu_position_gov)

egen freehms_z = std(freehms_st)
egen sociallifestyle_gov_z = std(sociallifestyle_gov)

egen immigr_z = std(immigr_st)
egen immigration_gov_z = std(immigration_gov)


sum lrscale_z lrgen_gov_z gincdif_z redistribution_gov_z eu_z eu_position_gov_z freehms_z sociallifestyle_gov_z immigr_z immigration_gov_z


**** Compute distances

*** Individual distance
* Left right
gen dist_lr_z=abs(lrscale_z-lrgen_gov_z)

* Redistribution
gen dist_redistr_z=abs(gincdif_z-redistribution_gov_z)

* EU integration
gen dist_eu_z=abs(eu_z-eu_position_gov_z)

* Social Lifestyle/Homosexuals
gen dist_lifestyle_z=abs(freehms_z-sociallifestyle_gov_z)

* Immigration
gen dist_immigr_z=abs(immigr_z-immigration_gov_z)

*** Median voter distance
* Left right
bysort cabinet_id: egen lrscale_z_med=median(lrscale_z)
gen dist_med_lr_z=abs(lrscale_z_med-lrgen_gov_z)

* Redistribution
bysort cabinet_id: egen gincdif_z_med=median(gincdif_z)
gen dist_med_redistr_z=abs(gincdif_z_med-redistribution_gov_z)

* EU integration
bysort cabinet_id: egen eu_z_med=median(eu_z)
gen dist_med_eu_z=abs(eu_z_med-eu_position_gov_z)

* Social Lifestyle/Homosexuals
bysort cabinet_id: egen freehms_z_med=median(freehms_z)
gen dist_med_lifestyle_z=abs(freehms_z_med-sociallifestyle_gov_z)

* Immigration
bysort cabinet_id: egen immigr_z_med=median(immigr_z)
gen dist_med_immigr_z=abs(immigr_z_med-immigration_gov_z)

*** Mean of single issues
gen dist_mean_z=(dist_redistr_z+dist_eu_z+dist_lifestyle_z+dist_immigr_z)/4
gen dist_med_mean_z=(dist_med_redistr_z+dist_med_eu_z+dist_med_lifestyle_z+dist_med_immigr_z)/4
	

* Left-right
mixed perc_responsiveness ///
	dist_lr_z dist_med_lr_z ///
	$controls || cntry: || cabinet_id: , stddeviations   	
	eststo m1
	
* All single issues
mixed perc_responsiveness ///
	dist_redistr_z dist_eu_z dist_lifestyle_z dist_immigr_z  ///
	dist_med_redistr_z dist_med_eu_z dist_med_lifestyle_z dist_med_immigr_z ///
	$controls || cntry: || cabinet_id: , stddeviations 	
	eststo m2
	
* Mean of single issues
mixed perc_responsiveness ///
	dist_mean_z dist_med_mean_z ///
	$controls || cntry: || cabinet_id: , stddeviations 	
	eststo m3

	sum dist_mean_z dist_med_mean_z if e(sample)
	
* Left-right, interaction egocentric and sociotropic
capture center dist_lr_z dist_med_lr_z

mixed perc_responsiveness ///
	c.c_dist_lr_z##c.c_dist_med_lr_z ///
	$controls || cntry: || cabinet_id: c.c_dist_lr_z, stddeviations   	
	eststo m4
	
	sum c_dist_lr_z c_dist_med_lr_z if e(sample)	
	
* Mean of single issues, interaction egocentric and sociotropic
capture center dist_mean_z dist_med_mean_z

mixed perc_responsiveness ///
	c.c_dist_mean_z##c.c_dist_med_mean_z ///
	$controls || cntry: ||  cabinet_id: c.c_dist_mean_z, stddeviations 	
	eststo m5
		
		
*** Table ****
esttab m1 m2 m3 m4 m5 using "RegTableD3.rtf", b(a2) se(a2) star(* 0.05 ** 0.01 *** 0.001) ///
		order(dist*) label nogaps nodepvars  ///
		replace			
	
	
	*** Figure D2: Effects of sociotropic distance on perceived responsiveness ****
					
			* Left-right 
			
			estimates restore m4
			
			sum c_dist_lr_z c_dist_med_lr_z if e(sample)
			sum c_dist_lr_z c_dist_med_lr_z if e(sample), d

			margins, dydx(c_dist_med_lr_z) at(c_dist_lr_z=(-1.2 (.1) 3)) post
			eststo marg5
			
			estimates restore marg5
				marginsplot, yline(0) ///
					addplot(hist c_dist_lr_z if e(sample), percent yaxis(2) yscale(alt range(0 50) axis(2)) ytitle(" ", size(zero) axis(2)) ylabel(none, axis(2)) xlabel(-1.5 (.5) 3, gmin gmax)) legend(off) ///
					title("Left-right (model 4)", size(medsmall)) ytitle("Effect on perceived responsiveness") xtitle("Egocentric distance") ///
					name(lefright_soceff, replace)

					
			* Mean distance		
					
			estimates restore m5
				
			sum c_dist_mean_z c_dist_med_mean_z if e(sample)
			sum c_dist_mean_z c_dist_med_mean_z if e(sample), d
				
			margins, dydx(c_dist_med_mean_z) at(c_dist_mean_z=(-.9 (.1) 2.4)) post
			eststo marg6
			
			estimates restore marg6
				marginsplot, yline(0) ///
					addplot(hist c_dist_mean_z if e(sample), percent yaxis(2) yscale(alt range(0 50) axis(2)) ytitle(" ", size(zero) axis(2)) ylabel(none, axis(2)) xlabel(-1.0 (.5) 2.5, gmin gmax)) legend(off) ///
					title("Mean distance (model 5)", size(medsmall)) ytitle("Effect on perceived responsiveness") xtitle("Egocentric distance") ///
					name(mean_soceff, replace)			
					

			* Combine the plots for the two models
			graph combine lefright_soceff mean_soceff, imargin(zero) iscale(*1.6) ycommon name(FigureD2, replace)			
					
			graph export "FigureD2.pdf", replace
			graph export "FigureD2.jpg", width(5000) replace
		
		
		
************************************************************************************************************************
*********************************************** Table D4: mean distance ************************************************
************************************************************************************************************************

*** Mean distance
* Left right
bysort cabinet_id: egen dist_mean_lr=mean(dist_lr)

* Redistribution
bysort cabinet_id: egen dist_mean_redistr=mean(dist_redistr)

* EU integration
bysort cabinet_id: egen dist_mean_eu=mean(dist_eu)

* Social Lifestyle/Homosexuals
bysort cabinet_id: egen dist_mean_lifestyle=mean(dist_lifestyle)

* Immigration
bysort cabinet_id: egen dist_mean_immigr=mean(dist_immigr)

*** Mean of single issues
capture gen dist_mean_mean=(dist_mean_redistr+dist_mean_eu+dist_mean_lifestyle+dist_mean_immigr)/4


* Left-right
mixed perc_responsiveness ///
	dist_lr dist_mean_lr ///
	$controls || cntry: || cabinet_id: , stddeviations   	
	eststo m1
	
* All single issues
mixed perc_responsiveness ///
	dist_redistr dist_eu dist_lifestyle dist_immigr  ///
	dist_mean_redistr dist_mean_eu dist_mean_lifestyle dist_mean_immigr ///
	$controls || cntry: || cabinet_id: , stddeviations 	
	eststo m2
	
* Mean of single issues
mixed perc_responsiveness ///
	dist_mean dist_mean_mean ///
	$controls || cntry: || cabinet_id: , stddeviations 	
	eststo m3

	sum dist_mean dist_mean_mean if e(sample)
	
* Left-right, interaction egocentric and sociotropic
capture center dist_mean_lr

mixed perc_responsiveness ///
	c.c_dist_lr##c.c_dist_mean_lr ///
	$controls || cntry: || cabinet_id: c.c_dist_lr, stddeviations   	
	eststo m4
	
	sum c_dist_lr c_dist_mean_lr if e(sample)	
	
* Mean of single issues, interaction egocentric and sociotropic
capture center dist_mean_mean

mixed perc_responsiveness ///
	c.c_dist_mean##c.c_dist_mean_mean ///
	$controls || cntry: ||  cabinet_id: c.c_dist_mean, stddeviations 	
	eststo m5
		
		
*** Table ****
esttab m1 m2 m3 m4 m5 using "RegTableD4.rtf", b(a2) se(a2) star(* 0.05 ** 0.01 *** 0.001) ///
		order(dist*) label nogaps nodepvars  ///
		replace			
		

	*** Figure D3: Effects of sociotropic distance on perceived responsiveness ****
					
			* Left-right 
			
			estimates restore m4
			
			sum c_dist_lr c_dist_mean_lr if e(sample)
			sum c_dist_lr c_dist_mean_lr if e(sample), d

			margins, dydx(c_dist_mean_lr) at(c_dist_lr=(-.25 (.05) .65)) post
			eststo marg5
			
			estimates restore marg5
				marginsplot, yline(0) ///
					addplot(hist c_dist_lr if e(sample), percent yaxis(2) yscale(alt range(0 50) axis(2)) ytitle(" ", size(zero) axis(2)) ylabel(none, axis(2)) xlabel(-.3 (.1) .7, gmin gmax)) legend(off) ///
					title("Left-right (model 4)", size(medsmall)) ytitle("Effect on perceived responsiveness") xtitle("Egocentric distance") ///
					name(lefright_soceff, replace)

					
			* Mean distance		
					
			estimates restore m5
				
			sum c_dist_mean c_dist_mean_mean if e(sample)
			sum c_dist_mean c_dist_mean_mean if e(sample), d
				
			margins, dydx(c_dist_mean_mean) at(c_dist_mean=(-.3 (.05) .6)) post
			eststo marg6
			
			estimates restore marg6
				marginsplot, yline(0) ///
					addplot(hist c_dist_mean if e(sample), percent yaxis(2) yscale(alt range(0 50) axis(2)) ytitle(" ", size(zero) axis(2)) ylabel(none, axis(2)) xlabel(-.3 (.1) .6, gmin gmax)) legend(off) ///
					title("Mean distance (model 5)", size(medsmall)) ytitle("Effect on perceived responsiveness") xtitle("Egocentric distance") ///
					name(mean_soceff, replace)			
					

			* Combine the plots for the two models
			graph combine lefright_soceff mean_soceff, imargin(zero) iscale(*1.6) ycommon name(FigureD3, replace)	
			
			graph export "FigureD3.pdf", replace
			graph export "FigureD3.jpg", width(5000) replace			
			

*************************************************************************************************************
*********************************************** Table D5: Additional macro controls *************************
*************************************************************************************************************

global controls "incumbent male i.age_groups ib4.education ib4.hinctnta_quint pol_interest_st"
global macrocontrols "v2x_polyarchy v2xdl_delib v2xdd_dd Gini_disp_pm"


*** Models  ****

* Left-right
mixed perc_responsiveness ///
	dist_lr dist_med_lr ///
	$controls $macrocontrols || cntry: || cabinet_id: , stddeviations   	
	eststo m1
	
* All single issues
mixed perc_responsiveness ///
	dist_redistr dist_eu dist_lifestyle dist_immigr  ///
	dist_med_redistr dist_med_eu dist_med_lifestyle dist_med_immigr ///
	$controls $macrocontrols || cntry: || cabinet_id: , stddeviations 	
	eststo m2
	
* Mean of single issues
mixed perc_responsiveness ///
	dist_mean dist_med_mean ///
	$controls $macrocontrols || cntry: || cabinet_id: , stddeviations 	
	eststo m3
	
* Left-right, interaction egocentric and sociotropic
mixed perc_responsiveness ///
	c.c_dist_lr##c.c_dist_med_lr ///
	$controls $macrocontrols || cntry: || cabinet_id: c.dist_lr, stddeviations   	
	eststo m4
		
* Mean of single issues, interaction egocentric and sociotropic
mixed perc_responsiveness ///
	c.c_dist_mean##c.c_dist_med_mean ///
	$controls $macrocontrols || cntry: || cabinet_id: c.dist_mean, stddeviations 	
	eststo m5
	
*** Table ****
esttab m1 m2 m3 m4 m5 using "RegTableD5.rtf", b(a2) se(a2) star(* 0.05 ** 0.01 *** 0.001) ///
		order(dist*) label nogaps nodepvars  ///
		replace			
	
	
		*** Figure D4: Effects of sociotropic distance on perceived responsiveness ****
					
			* Left-right 
			
			estimates restore m4
			
			sum c_dist_lr c_dist_med_lr if e(sample)
			sum c_dist_lr c_dist_med_lr if e(sample), d

			margins, dydx(c_dist_med_lr) at(c_dist_lr=(-.25 (.05) .65)) post
			eststo marg5
			
			estimates restore marg5
				marginsplot, yline(0) ///
					addplot(hist c_dist_lr if e(sample), percent yaxis(2) yscale(alt range(0 50) axis(2)) ytitle(" ", size(zero) axis(2)) ylabel(none, axis(2)) xlabel(-.3 (.1) .7, gmin gmax)) legend(off) ///
					title("Left-right (model 4)", size(medsmall)) ytitle("Effect on perceived responsiveness") xtitle("Egocentric distance") ///
					name(lefright_soceff, replace)

					
			* Mean distance		
					
			estimates restore m5
				
			sum c_dist_mean c_dist_med_mean if e(sample)
			sum c_dist_mean c_dist_med_mean if e(sample), d
				
			margins, dydx(c_dist_med_mean) at(c_dist_mean=(-.3 (.05) .5)) post
			eststo marg6
			
			estimates restore marg6
				marginsplot, yline(0) ///
					addplot(hist c_dist_mean if e(sample), percent yaxis(2) yscale(alt range(0 50) axis(2)) ytitle(" ", size(zero) axis(2)) ylabel(none, axis(2)) xlabel(-.3 (.1) .5, gmin gmax)) legend(off) ///
					title("Mean distance (model 5)", size(medsmall)) ytitle("Effect on perceived responsiveness") xtitle("Egocentric distance") ///
					name(mean_soceff, replace)			
					

			* Combine the plots for the two models
			graph combine lefright_soceff mean_soceff, imargin(zero) iscale(*1.6) ycommon name(FigureD4, replace)			
						
			graph export "FigureD4.pdf", replace
			graph export "FigureD4.jpg", width(5000) replace
	
	
************************************************************************************************************************
*********************************************** Table D6: Without Switzerland ******************************************
************************************************************************************************************************	

*** Models  ****

* Left-right
mixed perc_responsiveness ///
	dist_lr dist_med_lr ///
	$controls || cntry: || cabinet_id: if cntry!="CH", stddeviations   	
	eststo m1
	
* All single issues
mixed perc_responsiveness ///
	dist_redistr dist_eu dist_lifestyle dist_immigr  ///
	dist_med_redistr dist_med_eu dist_med_lifestyle dist_med_immigr ///
	$controls || cntry: || cabinet_id: if cntry!="CH", stddeviations 	
	eststo m2
	
* Mean of single issues
mixed perc_responsiveness ///
	dist_mean dist_med_mean ///
	$controls || cntry: || cabinet_id: if cntry!="CH", stddeviations 	
	eststo m3
	
* Left-right, interaction egocentric and sociotropic
mixed perc_responsiveness ///
	c.c_dist_lr##c.c_dist_med_lr ///
	$controls || cntry: || cabinet_id: c.dist_lr if cntry!="CH", stddeviations   	
	eststo m4
		
* Mean of single issues, interaction egocentric and sociotropic
mixed perc_responsiveness ///
	c.c_dist_mean##c.c_dist_med_mean ///
	$controls || cntry: ||  cabinet_id: c.dist_mean if cntry!="CH", stddeviations 	
	eststo m5
		
*** Table ****
esttab m1 m2 m3 m4 m5 using "RegTableD6.rtf", b(a2) se(a2) star(* 0.05 ** 0.01 *** 0.001) ///
		order(dist*) label nogaps nodepvars  ///
		replace	
	
	
		*** Figure D5: Effects of sociotropic distance on perceived responsiveness ****
					
			* Left-right 
			
			estimates restore m4
			
			sum c_dist_lr c_dist_med_lr if e(sample)
			sum c_dist_lr c_dist_med_lr if e(sample), d

			margins, dydx(c_dist_med_lr) at(c_dist_lr=(-.25 (.05) .65)) post
			eststo marg5
			
			estimates restore marg5
				marginsplot, yline(0) ///
					addplot(hist c_dist_lr if e(sample), percent yaxis(2) yscale(alt range(0 50) axis(2)) ytitle(" ", size(zero) axis(2)) ylabel(none, axis(2)) xlabel(-.3 (.1) .7, gmin gmax)) legend(off) ///
					title("Left-right (model 4)", size(medsmall)) ytitle("Effect on perceived responsiveness") xtitle("Egocentric distance") ///
					name(lefright_soceff, replace)

					
			* Mean distance		
					
			estimates restore m5
				
			sum c_dist_mean c_dist_med_mean if e(sample)
			sum c_dist_mean c_dist_med_mean if e(sample), d
				
			margins, dydx(c_dist_med_mean) at(c_dist_mean=(-.3 (.05) .6)) post
			eststo marg6
			
			estimates restore marg6
				marginsplot, yline(0) ///
					addplot(hist c_dist_mean if e(sample), percent yaxis(2) yscale(alt range(0 50) axis(2)) ytitle(" ", size(zero) axis(2)) ylabel(none, axis(2)) xlabel(-.3 (.1) .6, gmin gmax)) legend(off) ///
					title("Mean distance (model 5)", size(medsmall)) ytitle("Effect on perceived responsiveness") xtitle("Egocentric distance") ///
					name(mean_soceff, replace)			
					

			* Combine the plots for the two models
			graph combine lefright_soceff mean_soceff, imargin(zero) iscale(*1.6) ycommon name(FigureD5, replace)			
						
			graph export "FigureD5.pdf", replace
			graph export "FigureD5.jpg", width(5000) replace	
	
	
************************************************************************************************************************
********************************** Table D7: Separate models for Western and Eastern Europe ****************************
************************************************************************************************************************	
	
*** Western Europe
* Left-right
	mixed perc_responsiveness ///
		dist_lr dist_med_lr ///
		$controls if east==0 || cntry: || cabinet_id: , stddeviations   	
		eststo m1_west

* All single issues
	mixed perc_responsiveness ///
		dist_redistr dist_eu dist_lifestyle dist_immigr  ///
		dist_med_redistr dist_med_eu dist_med_lifestyle dist_med_immigr ///
		$controls if east==0 || cntry: || cabinet_id: , stddeviations 	
		eststo m2_west
	
* Mean of single issues
	mixed perc_responsiveness ///
		dist_mean dist_med_mean ///
		$controls if east==0 || cntry: || cabinet_id: , stddeviations 	
		eststo m3_west
	
* Left-right, interaction egocentric and sociotropic
	mixed perc_responsiveness ///
		c.c_dist_lr##c.c_dist_med_lr ///
		$controls if east==0 || cntry: || cabinet_id: c.dist_lr, stddeviations   	
		eststo m4_west
	
* Mean of single issues, interaction egocentric and sociotropic
	mixed perc_responsiveness ///
		c.c_dist_mean##c.c_dist_med_mean ///
		$controls if east==0 || cntry: ||  cabinet_id: c.dist_mean, stddeviations 	
		eststo m5_west

		
*** Eastern Europe
* Left-right
	mixed perc_responsiveness ///
		dist_lr dist_med_lr ///
		$controls if east==1 || cntry: || cabinet_id: , stddeviations reml 	
		eststo m1_east

* All single issues
	mixed perc_responsiveness ///
		dist_redistr dist_eu dist_lifestyle dist_immigr  ///
		dist_med_redistr dist_med_eu dist_med_lifestyle dist_med_immigr ///
		$controls if east==1 || cntry: || cabinet_id: , stddeviations 	
		eststo m2_east

* Mean of single issues
	mixed perc_responsiveness ///
		dist_mean dist_med_mean ///
		$controls if east==1 || cntry: || cabinet_id: , stddeviations 	
		eststo m3_east
	
* Left-right, interaction egocentric and sociotropic
	mixed perc_responsiveness ///
		c.c_dist_lr##c.c_dist_med_lr ///
		$controls if east==1 || cntry: || cabinet_id: c.dist_lr, stddeviations   	
		eststo m4_east
	
* Mean of single issues, interaction egocentric and sociotropic
	mixed perc_responsiveness ///
		c.c_dist_mean##c.c_dist_med_mean ///
		$controls if east==1 || cntry: ||  cabinet_id: c.dist_mean, stddeviations 	
		eststo m5_east
		
		
*** Write regression table ****
	esttab m1_west m1_east m2_west m2_east m3_west m3_east m4_west m4_east m5_west m5_east using "RegTableD7.rtf", b(a2) se(a2) star(* 0.05 ** 0.01 *** 0.001) ///
			order(dist*) label nogaps nodepvars  ///
			replace				
	
	
		*** Figure D6: Effects of sociotropic distance on perceived responsiveness ****
					
			* West
			
			* Left-right 
			
			estimates restore m4_west
			
			sum c_dist_lr c_dist_med_lr if e(sample)
			sum c_dist_lr c_dist_med_lr if e(sample), d

			margins, dydx(c_dist_med_lr) at(c_dist_lr=(-.25 (.05) .65)) post
			eststo marg5
			
			estimates restore marg5
				marginsplot, yline(0) ///
					addplot(hist c_dist_lr if e(sample), percent yaxis(2) yscale(alt range(0 50) axis(2)) ytitle(" ", size(zero) axis(2)) ylabel(none, axis(2)) xlabel(-.3 (.1) .7, gmin gmax)) legend(off) ///
					title("Left-right (model 4)", size(medsmall)) ytitle("Effect on perceived responsiveness") xtitle("Egocentric distance") ///
					name(lefright_soceff_west, replace)
					
			* Mean distance		
					
			estimates restore m5_west
				
			sum c_dist_mean c_dist_med_mean if e(sample)
			sum c_dist_mean c_dist_med_mean if e(sample), d
				
			margins, dydx(c_dist_med_mean) at(c_dist_mean=(-.3 (.05) .6)) post
			eststo marg6
			
			estimates restore marg6
				marginsplot, yline(0) ///
					addplot(hist c_dist_mean if e(sample), percent yaxis(2) yscale(alt range(0 50) axis(2)) ytitle(" ", size(zero) axis(2)) ylabel(none, axis(2)) xlabel(-.3 (.1) .6, gmin gmax)) legend(off) ///
					title("Mean distance (model 5)", size(medsmall)) ytitle("Effect on perceived responsiveness") xtitle("Egocentric distance") ///
					name(mean_soceff_west, replace)		
					
			* Combine the plots for the two models
			graph combine lefright_soceff_west mean_soceff_west, imargin(zero) iscale(*1.6) ycommon title("Western Europe") name(west, replace)			
					
					
			* East
			
			* Left-right 
			
			estimates restore m4_east
			
			sum c_dist_lr c_dist_med_lr if e(sample)
			sum c_dist_lr c_dist_med_lr if e(sample), d

			margins, dydx(c_dist_med_lr) at(c_dist_lr=(-.25 (.05) .65)) post
			eststo marg5
			
			estimates restore marg5
				marginsplot, yline(0) ///
					addplot(hist c_dist_lr if e(sample), percent yaxis(2) yscale(alt range(0 50) axis(2)) ytitle(" ", size(zero) axis(2)) ylabel(none, axis(2)) xlabel(-.3 (.1) .7, gmin gmax)) legend(off) ///
					title("Left-right (model 4)", size(medsmall)) ytitle("Effect on perceived responsiveness") xtitle("Egocentric distance") ///
					name(lefright_soceff_east, replace)
					
			* Mean distance		
					
			estimates restore m5_east
				
			sum c_dist_mean c_dist_med_mean if e(sample)
			sum c_dist_mean c_dist_med_mean if e(sample), d
				
			margins, dydx(c_dist_med_mean) at(c_dist_mean=(-.3 (.05) .6)) post
			eststo marg6
			
			estimates restore marg6
				marginsplot, yline(0) ///
					addplot(hist c_dist_mean if e(sample), percent yaxis(2) yscale(alt range(0 50) axis(2)) ytitle(" ", size(zero) axis(2)) ylabel(none, axis(2)) xlabel(-.3 (.1) .6, gmin gmax)) legend(off) ///
					title("Mean distance (model 5)", size(medsmall)) ytitle("Effect on perceived responsiveness") xtitle("Egocentric distance") ///
					name(mean_soceff_east, replace)
					
			* Combine the plots for the two models
			graph combine lefright_soceff_east mean_soceff_east, imargin(zero) iscale(*1.6) ycommon title("Eastern Europe") name(east, replace)			
						
			graph combine west east, row(2) ysize(7) name(FigureD6, replace)
	
			graph export "FigureD6.pdf", replace
			graph export "FigureD6.jpg", width(5000) replace	
	
	
************************************************************************************************************************
*********************************************** Table D8: Ordered Logit ************************************************
************************************************************************************************************************	

global controls "incumbent male i.age_groups ib4.education ib4.hinctnta_quint pol_interest_st"

*** Models  ****

// Note: Estimated with only two models due to convergence problems

* Left-right
meologit perc_responsiveness ///
	dist_lr dist_med_lr ///
	$controls || cabinet_id: 
	eststo m1

* All single issues
meologit perc_responsiveness ///
	dist_redistr dist_eu dist_lifestyle dist_immigr  ///
	dist_med_redistr dist_med_eu dist_med_lifestyle dist_med_immigr ///
	$controls || cabinet_id: 
	eststo m2
	
* Mean of single issues
meologit perc_responsiveness ///
	dist_mean dist_med_mean ///
	$controls || cabinet_id: 
	eststo m3
	
* Left-right, interaction egocentric and sociotropic
meologit perc_responsiveness ///
	c.c_dist_lr##c.c_dist_med_lr ///
	$controls || cabinet_id: c.dist_lr
	eststo m4
	
* Mean of single issues, interaction egocentric and sociotropic
meologit perc_responsiveness ///
	c.c_dist_mean##c.c_dist_med_mean ///
	$controls || cabinet_id: c.dist_mean
	eststo m5
		
		
*** Table ****
esttab m1 m2 m3 m4 m5 using "RegTableD8.rtf", b(a2) se(a2) star(* 0.05 ** 0.01 *** 0.001) ///
		order(dist*) label nogaps nodepvars  ///
		replace			

		graph export "FigureD8.pdf", replace
		graph export "FigureD8.jpg", width(5000) replace			
		
		
************************************************************************************************************************
*********************************************** Table D9: Binary Logit *************************************************
************************************************************************************************************************	

global controls "incumbent male i.age_groups ib4.education ib4.hinctnta_quint pol_interest_st"

recode perc_responsiveness (0/5=0) (6/10=1), gen(perc_resp_dummy) 

*** Models  ****

* Left-right
melogit perc_resp_dummy ///
	dist_lr dist_med_lr ///
	$controls || cntry: || cabinet_id: 
	eststo m1
	
* All single issues
melogit perc_resp_dummy ///
	dist_redistr dist_eu dist_lifestyle dist_immigr  ///
	dist_med_redistr dist_med_eu dist_med_lifestyle dist_med_immigr ///
	$controls || cntry: || cabinet_id: 
	eststo m2
	
* Mean of single issues
melogit perc_resp_dummy ///
	dist_mean dist_med_mean ///
	$controls || cntry: || cabinet_id: , difficult
	
melogit perc_resp_dummy ///
	dist_mean dist_med_mean ///
	$controls || cntry: || cabinet_id: , difficult
	
	eststo m3
	
* Left-right, interaction egocentric and sociotropic
melogit perc_resp_dummy ///
	c.c_dist_lr##c.c_dist_med_lr ///
	$controls || cntry: || cabinet_id: c.dist_lr
	eststo m4
		
* Mean of single issues, interaction egocentric and sociotropic
melogit perc_resp_dummy ///
	c.c_dist_mean##c.c_dist_med_mean ///
	$controls || cntry: || cabinet_id: c.dist_mean
	eststo m5
		
		
*** Table ****
esttab m1 m2 m3 m4 m5 using "RegTableD9.rtf", b(a2) se(a2) star(* 0.05 ** 0.01 *** 0.001) ///
		order(dist*) label nogaps nodepvars  ///
		replace			

	
		*** Figure D7: Effects of sociotropic distance on perceived responsiveness ****
					
			* Left-right 
			
			estimates restore m4
			
			sum c_dist_lr c_dist_med_lr if e(sample)
			sum c_dist_lr c_dist_med_lr if e(sample), d

			margins, dydx(c_dist_med_lr) at(c_dist_lr=(-.25 (.05) .65)) post
			eststo marg5
			
			estimates restore marg5
				marginsplot, yline(0) ///
					addplot(hist c_dist_lr if e(sample), percent yaxis(2) yscale(alt range(0 50) axis(2)) ytitle(" ", size(zero) axis(2)) ylabel(none, axis(2)) xlabel(-.3 (.1) .7, gmin gmax)) legend(off) ///
					title("Left-right (model 4)", size(medsmall)) ytitle("Effect on perceived responsiveness") xtitle("Egocentric distance") ///
					name(lefright_soceff, replace)

					
			* Mean distance		
					
			estimates restore m5
				
			sum c_dist_mean c_dist_med_mean if e(sample)
			sum c_dist_mean c_dist_med_mean if e(sample), d
				
			margins, dydx(c_dist_med_mean) at(c_dist_mean=(-.3 (.05) .6)) post
			eststo marg6
			
			estimates restore marg6
				marginsplot, yline(0) ///
					addplot(hist c_dist_mean if e(sample), percent yaxis(2) yscale(alt range(0 50) axis(2)) ytitle(" ", size(zero) axis(2)) ylabel(none, axis(2)) xlabel(-.3 (.1) .6, gmin gmax)) legend(off) ///
					title("Mean distance (model 5)", size(medsmall)) ytitle("Effect on perceived responsiveness") xtitle("Egocentric distance") ///
					name(mean_soceff, replace)			
					

			* Combine the plots for the two models
			graph combine lefright_soceff mean_soceff, imargin(zero) iscale(*1.6) ycommon name(FigureD7, replace)		
	
			graph export "FigureD7.pdf", replace
			graph export "FigureD7.jpg", width(5000) replace
	
	
************************************************************************************************************************
*********************************************** Table D10: Combined DV *************************************************
************************************************************************************************************************	


	*** Perceived reponsiveness: "How often you think the government changes its planned policies in response to what most people think'?"
	fre perc_responsiveness
	
	*** "How often you think the government sticks to its planned policies regardless of what most people think?"
	fre stpldmc	
	
	* Combine variables
	clonevar perc_responsiveness_comb=perc_responsiveness
	replace perc_responsiveness_comb=(-stpldmc+10) if perc_responsiveness>=.

	* define macro with control variables
	global controls "incumbent male i.age_groups ib4.education ib4.hinctnta_quint pol_interest_st"


*** Models

* Left-right
	mixed perc_responsiveness_comb ///
		dist_lr dist_med_lr ///
		$controls || cntry: || cabinet_id: , stddeviations   	
		eststo m1

* All single issues
	mixed perc_responsiveness_comb ///
		dist_redistr dist_eu dist_lifestyle dist_immigr  ///
		dist_med_redistr dist_med_eu dist_med_lifestyle dist_med_immigr ///
		$controls || cntry: || cabinet_id: , stddeviations 	
		eststo m2
	
* Mean of single issues
	mixed perc_responsiveness_comb ///
		dist_mean dist_med_mean ///
		$controls || cntry: || cabinet_id: , stddeviations 	
		eststo m3
	
* Left-right, interaction egocentric and sociotropic
	mixed perc_responsiveness_comb ///
		c.c_dist_lr##c.c_dist_med_lr ///
		$controls || cntry: || cabinet_id: c.dist_lr, stddeviations   	
		eststo m4
	
* Mean of single issues, interaction egocentric and sociotropic
	mixed perc_responsiveness_comb ///
		c.c_dist_mean##c.c_dist_med_mean ///
		$controls || cntry: ||  cabinet_id: c.dist_mean, stddeviations 	
		eststo m5
		
*** Write regression table ****
	esttab m1 m2 m3 m4 m5 using "RegTableD10.rtf", b(a2) se(a2) star(* 0.05 ** 0.01 *** 0.001) ///
			order(dist*) label nogaps nodepvars  ///
			replace

			
			
************************************************************************************************************************
************************************* Table D11: Interaction of congruence with political interest *********************
************************************************************************************************************************

recode pol_interest (0 1=0 "pol. interest: low") (2 3=1 "pol. interest: high"), gen(pol_interest_dummy)

global controls "incumbent male i.age_groups ib4.education ib4.hinctnta_quint"

* Left-right
mixed perc_responsiveness ///
	c.dist_lr##ib1.pol_interest_dummy c.dist_med_lr##ib1.pol_interest_dummy ///
	$controls || cntry: || cabinet_id: ib1.pol_interest_dummy , stddeviations   	
	eststo m1

* Mean of single issues
mixed perc_responsiveness ///
	c.dist_mean##ib1.pol_interest_dummy c.dist_med_mean##ib1.pol_interest_dummy ///
	$controls || cntry: || cabinet_id: ib1.pol_interest_dummy , stddeviations 	
	eststo m2
	

*** Table ****
esttab m1 m2 using "RegTableD11.rtf", b(a2) se(a2) star(* 0.05 ** 0.01 *** 0.001) ///
		order(dist*) label nogaps nodepvars  ///
		replace		

**** Pol. interest X Distance interaction				

	* Left-right
	estimates restore m1
				
		margins, dydx(dist_lr) at(pol_interest_dummy=(0 1))
		marginsplot, recast(scatter) horizontal ///
			xtitle(" ", size(tiny)) ytitle(" ", size(tiny)) title("egocentric distance", size(small)) ///
			xline(0) ///
			name(gr1, replace)
		
		margins, dydx(dist_med_lr) at(pol_interest_dummy=(0 1))
		marginsplot, recast(scatter) horizontal ///
			xtitle(" ", size(tiny)) ytitle(" ", size(tiny)) title("sociotropic distance", size(small)) ///
			xline(0) ///
			name(gr2, replace)

		graph combine gr1 gr2, xcommon row(2) iscale(*1.6) imargin(zero) title("Left-right scale (model 1)") ///
			name(Polint_LR, replace)
		
	* Mean distance		
	estimates restore m2
	
		margins, dydx(dist_mean) at(pol_interest_dummy=(0 1))
		marginsplot, recast(scatter) horizontal ///
			xtitle(" ", size(tiny)) ytitle(" ", size(tiny)) title("egocentric distance", size(small)) ///
			xline(0) ///
			name(gr1, replace)
		
		margins, dydx(dist_med_mean) at(pol_interest_dummy=(0 1))
		marginsplot, recast(scatter) horizontal ///
			xtitle(" ", size(tiny)) ytitle(" ", size(tiny)) title("sociotropic distance", size(small)) ///
			xline(0) ///
			name(gr2, replace)

		graph combine gr1 gr2, xcommon row(2) iscale(*1.6) imargin(zero) title("Mean distance (model 2)") ///
			name(Polint_mean, replace)
			
		graph combine Polint_LR Polint_mean, iscale(*1.4) name(FigureD8, replace)
		
			graph export "FigureD8.pdf", replace
			graph export "FigureD8.jpg", width(5000) replace
		
		
log close